package net.hserver.admin.system.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Set;

/**
 * 用户信息
 *
*
 * @since 2022-06-12
 */
@Getter
@Setter
@Table(value = "tab_user")
public class User {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @Id(value = "user_id", keyType = KeyType.Auto)
    private Long userId;

    /**
     * 账号
     */
    private String username;

    /**
     * 密码
     */
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private String password;

    /**
     * 姓名
     */
    private String nickname;

    /**
     * 手机
     */
    private String phone;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 头像
     */
    private String avatar;

    /**
     * 是否冻结
     */
    private Boolean locked;

    /**
     * 乐观锁
     */
    @Column(onUpdateValue = "version + 1")
    private Long version;

    /**
     * 逻辑删除
     */
    @Column(isLogicDelete = true)
    private Boolean deleted;

    /**
     * 创建时间
     */
    @Column(onInsertValue = "now()")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @Column(onUpdateValue = "now()", onInsertValue = "now()")
    private LocalDateTime updateTime;

    /**
     * 角色ID集合
     */
    @Column(ignore = true)
    private Set<Long> roleIds;

    /**
     * 权限集合
     */
    @Column(ignore = true)
    private Set<String> permissions;

}
